<header id="topbar">
    <div class="topbar-left">
        <ol class="breadcrumb">
            <li class="crumb-active">
                <a href="#report/activity/">每日购彩统计</a>
            </li>
        </ol>
    </div>
</header>
<section id="content">
    <div class="panel">
        <form class="form-horizontal" role="form">
            <div class="form-group" style="display: flex">
                <div class="margin" style="width: 400px;">
                    <input type="text" id="dateFilter" style="margin-top: 0" class="form-control text-center " value="<%= options.dateRange[0] %> ~ <%= options.dateRange[1] %>">
                </div>
                <div class="margin">
                    <label for="searchActivityType" class="field select">
                        <select id="searchActivityType" name="searchActivityType" data-field="activity_type" style="width: 200px;height:35px">
                            <option value="-1" >所有</option>
                            <% _.each(LOTTERY_TYPE, function(v, k){%>
                                 <option value="<%= k %>" <%= searched.activity_type == k ? 'selected' : '' %>> <%= v %> </option>
                            <% }) %>
                        </select>
                        <i class="arrow double"></i>
                    </label>
                    <i class="arrow doube"></i>
                </div>
                <div class="margin">
                    <label for="searchBetType" class="field select">
                        <select id="searchBetType" name="searchBetType" data-field="bet_type" style="width: 200px;height:35px">
                            <option value="-2" <%= searched.bet_type == -2 ? 'selected' : '' %>>所有(单条数据)</option>
                            <option value="-1" <%= searched.bet_type == -1 ? 'selected' : '' %>>所有(汇总数据)</option>
                            <% _.each(bet_list, function(v, k){%>
                                <option value="<%= k %>" <%= searched.bet_type == k ? 'selected' : '' %>><%= v %></option>
                            <% }) %>
                        </select>
                        <i class="arrow double"></i>
                    </label>
                    <i class="arrow doube"></i>
                </div>

                <div style="margin: -8px 20px;">
                    <input type="button" id="search" class="btn btn-primary btn-block form-control" value="提交">
                </div>
            </div>
        </form>
    </div>

    <div class="panel">
        <table class="table table-striped fs13" id="main-list">
            <thead>
                <tr class="bg-light">
                    <th class="sortable" data-field="date">日期</th>
                    <th class="sortable" data-field="activity_type">彩种</th>
                    <th class="sortable" data-field="bet_type">玩法</th>
                    <th class="sortable" data-field="pay_total">购彩金额</th>
                    <th class="sortable" data-field="pay_users">购彩人数</th>
                    <th class="sortable" data-field="win_total">中奖金额</th>
                    <th class="sortable" data-field="win_users">中奖人数</th>
                    <th class="sortable" data-field="refund_total">退款金额</th>
                    <th class="sortable" data-field="gain_total">盈利金额</th>
                    <th>抽水率</th>
                </tr>
            </thead>
            <tbody class="admin-form">
                <% _.each(items, function(item){
                    var bet = window.BET_TYPE[item.activity_type]%>
                    <tr>
                        <td><%= item.date %></td>
                        <td><%= item.activity_type ? window.LOTTERY_TYPE[item.activity_type] : '' %></td>
                        <td><%= item.bet_type ? bet[item.bet_type] : '' %></td>
                        <td><%= (item.pay_total || 0).toFixed(2) %></td>
                        <td><%= item.pay_users %></td>
                        <td><%= (item.win_total || 0).toFixed(2)%></td>
                        <td><%= item.win_users %></td>
                        <td><%= (item.refund_total || 0).toFixed(2)%></td>
                        <td><%= ((item.gain_total || 0)  - (item.refund_total||0)).toFixed(2)%></td>
                        <td><%= (((item.gain_total || 0) - (item.refund_total || 0)) / (item.pay_total - item.refund_total) * 100).toFixed(2) %> % </td>
                    </tr>
                <% }) %>
            </tbody>
        </table>
    </div>

    <% if(items.length > 0 && !items[0].bet_type){ %>
    <div class="panel">
        <div class="panel-heading">
					<span class="panel-icon"><i class="fa fa-star text-primary"></i>
                    </span>
                <span class="panel-title">彩种分析</span>
        </div>
        <div class="panel-body">
            <div class="col-md-3">
                <dl class="dl-horizontal">
                    <dt>所选时间,彩种的数据总额:</dt>
                    <dd></dd>
                    <dt>购彩金额:</dt>
                    <dd> <%= (sum.pay_total ||0).toFixed(2) %></dd>
                    <dt>购彩人数:</dt>
                    <dd> <%= (sum.pay_users ||0).toFixed(2) %></dd>
                    <dt>中奖／加奖金额</dt>
                    <dd> <%= (sum.win_total ||0).toFixed(2) %></dd>
                    <dt>中奖人数:</dt>
                    <dd><%= sum.win_users %></dd>
                    <dt>退款金额:</dt>
                    <dd><%= (sum.refund_total ||0).toFixed(2) %></dd>
                    <dt>抽水</dt>
                    <dd><%= ((sum.gain_total||0) - (sum.refund_total||0)).toFixed(2) %></dd>
                    <dt>抽水率</dt>
                    <dd><%= (((sum.gain_total||0) - (sum.refund_total||0)) / ((sum.pay_total ||0) - (sum.refund_total||0)) * 100).toFixed(2) %> % </dd>
                </dl>
            </div>
            <div class="col-md-4">
                <div id="pay-total-dist"></div>
            </div>
            <div class="col-md-4">
                <div id="pay-users-dist"></div>
            </div>
        </div>
    </div>
    <%}%>
</section>

<style>
    .margin{
        margin: 10px 20px;
    }
</style>
